package partitionBean;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import serializeBean.FlowBean;

import java.io.IOException;

public class FlowCountMapper extends Mapper<LongWritable,Text,Text, FlowBean> {

    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] fields = line.split("\t");
        String phoneNumber = fields[0];
        Long upFlow = Long.parseLong(fields[1]);
        Long downFlow = Long.parseLong(fields[2]);
        context.write(new Text(phoneNumber), new FlowBean(upFlow, downFlow));
    }
}
